fix: loop-back retry error handler to merge before source activity (#506)#507
Open
hjotha wants to merge 1 commit intomendixlabs:mainfrom
Open
fix: loop-back retry error handler to merge before source activity (#506)#507hjotha wants to merge 1 commit intomendixlabs:mainfrom
hjotha wants to merge 1 commit intomendixlabs:mainfrom
Conversation
…ource When a call activity with a custom error handler has a body ending in an IF where exactly one branch terminates (via RAISE ERROR or RETURN), the authored Studio Pro topology uses a merge placed before the source activity with the non-terminating branch looping back to that merge — implementing a retry pattern. MDL has no surface syntax for the loop-back edge, so previously the builder emitted a linear topology that placed the merge after the source, which moved subsequent activities' references to the call's output variable out of scope and triggered CE0108 "Variable X is defined but not in scope" in mx check. Detect the pattern via isRetryLoopErrorHandler (last statement is an IF with exactly one terminating branch) and build the loop-back topology directly in buildRetryLoopErrorHandler: a new merge is placed just left of the source activity, the handler tail's exit connects to the merge as a plain SequenceFlow (the IsErrorHandler edge is already on the source → first-handler-activity connection), and fb.incomingRedirect redirects the outer loop's inbound flow to terminate at the merge. A repro (mxcli exec of a rest-call-with-retry microflow into a blank MPR, then mx check) now reports 0 errors on the simple case; before this fix it reported CE0108. Non-retry error handlers still use the existing forward-merge path. Related: tracked in mendixlabs#506. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
AI Code ReviewCritical IssuesNone found. Moderate IssuesNone found. Minor IssuesNone found. What Looks Good
RecommendationApprove the PR. The change is minimal, well-tested, and precisely solves the reported CE0108 scope issue for retry-loop error handlers while maintaining backward compatibility for other error handler patterns. No checklist violations were identified. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
raise errororreturn) and the other performs retry actions, the builder now reproduces the Studio Pro authored topology: a merge is inserted just before the source activity, and the non-terminating branch's tail loops back to that merge. Previously the builder emitted a linear topology that placed the merge after the source, moving the call's output variable out of scope for downstream activities and triggeringCE0108 "Variable X is defined but not in scope"onmx check.isRetryLoopErrorHandlerdetects the pattern (trailing IF with exactly-one-terminating branch) and routes through a newbuildRetryLoopErrorHandlerhelper. Non-retry error handlers still use the existing forward-merge path.flowBuilder.incomingRedirectfield lets the outer loop inbuildFlowGraphredirect the next inbound flow to the pre-source merge instead of the source activity itself.Reproduction & validation
Minimal MDL:
Before this PR:
mxcli execfollowed bymx checkreportsCE0108. After this PR:mx checkreports 0 errors. Additional downstreammx checkdiagnostics that surface after the scope fix are pre-existing describer/builder issues in retrieve-chain-over-mapping and are independent of this change.Test plan
TestRetryLoopErrorHandlerLoopsBackToSource— verifies the retry shape producesprev->merge->source,tail->merge, and no directprev->sourceedge.TestNonRetryErrorHandlerUsesForwardMerge— guards the opposite path (non-retry handlers must not introduce a merge).go test ./...passes.mx checkerrors = 0; before this PR it reportedCE0108.🤖 Generated with Claude Code